<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>

let big= Number.MAX_SAFE_INTEGER;  //最大数字

let cn = [
    {begin:5000, end:8000 , rax:0.03},
    {begin:8000, end:17000 , rax:0.1},
    {begin:17000, end:30000 , rax:0.2},
    {begin:30000, end:40000 , rax:0.25},
    {begin:40000, end:60000 , rax:0.3},
    {begin:60000, end:85000 , rax:0.35},
    {begin:85000, end: big, rax:0.45}
];
let i =0;
let money = 18000;
let rax = 0 ;

for(i=0;i< cn.length ;i++){
    let c = cn[i];
    console.log( c );
    if(money >= c.end ){ 
        rax += (c.end - c.begin) * c.rax;
    }else{
       rax += (money-c.begin)* c.rax;
       break;
    }
}

console.log( '月薪=',money,'税= ' + rax);
console.log( '税后= ' + (money - rax) );
console.log( '年薪= ' + (money - rax)*12 );

</script>
</body>
</html>